# Maintainer: Rafał Brzegowy <rafal.brzegowy@yahoo.com>

_realname=starpu
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.4.0
pkgrel=2
pkgdesc='StarPU is a task programming library for hybrid architectures (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
depends=("${MINGW_PACKAGE_PREFIX}-fftw"
         "${MINGW_PACKAGE_PREFIX}-hwloc"
         "${MINGW_PACKAGE_PREFIX}-libwinpthread-git"
         "${MINGW_PACKAGE_PREFIX}-opencl-icd"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-autotools"
  "${MINGW_PACKAGE_PREFIX}-opencl-headers"
)
options=('!docs')
license=('LGPL')
url='https://starpu.gitlabpages.inria.fr'
source=(https://files.inria.fr/starpu/${_realname}-${pkgver}/${_realname}-${pkgver}.tar.gz
        "0001-fix-callback-missing-stdcall.patch")
sha256sums=('5058127761a0604606a852fd6d20b07040d5fbd9f798c5383e49f336b4eeaca1'
            '0c03204c893e2e00879e9a14f29696e5a3f9adf7af1092ca01e747f01b272512')

prepare() {
  cd ${_realname}-${pkgver}

  patch -Np1 -i "${srcdir}/0001-fix-callback-missing-stdcall.patch"

  autoreconf -fiv
}

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --with-gnu-ld \
    --disable-mpi \
    --disable-build-doc \
    --disable-build-examples \
    --enable-quick-check \
    --disable-gdb \
    --enable-opencl \
    --enable-socl

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  make check || true
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 ${srcdir}/${_realname}-${pkgver}/COPYING.LGPL ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}

# vim: ts=2 sw=2 et:
